<?php

namespace app\test518\controller;

use think\Controller;
use Validate;
use FormBuilder\Factory\Elm;

class Login extends Controller
{
    /**
     * 登录页面请求
     *Method index
     *user:大飞
     *time:2021/5/18 8:39
     */
    public function index()
    {
        $action = "/test518/login/login";
        $method = 'POST';

        $input = Elm::input('username', '用户名')->required();
        $input1 = Elm::input('password', '密码','','password');
        $input2 = Elm::input('tel', '手机号','','number');
        $input3 = Elm::radio('sex','性别','1');
        $switch = Elm::switches('is_open', '是否开启')->activeText('开启')->inactiveText('关闭');


//创建表单
        $form = Elm::createForm($action)->setMethod($method);

//添加组件
        $form->setTitle('登录');
        $form->setRule([$input, $input1,$input2,$input3]);
        $form->append($switch);


//生成表单页面
        echo $formHtml = $form->view();
        //return view('admin/index');
    }


    /**处理登录信息
     *Method login
     *user:大飞
     *time:2021/5/18 16:19
     */
    public function login()
    {
        //接收值
        $data = input();


        dump($data);
        die();
    }
}
